//
//  RfppUcHistoryViewController.swiftFXxGAR
//  QRScan
//
//  Created by Qiang on 2018/3/27.
//  Copyright © 2018年 Qiang. All rights reserved.
//

import UIKit

class RfppUcHistoryViewController: JGayoKJCBaseViewController,UITableViewDelegate,UITableViewDataSource {
   
    var historyArray = NSMutableArray(capacity: 0)
    

    @IBOutlet weak var tableview: UITableView!
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "history"
        self.tableview.separatorStyle = .none
        if UserDefaults.standard.object(forKey: "history") != nil {
            historyArray = (UserDefaults.standard.object(forKey: "history") as! NSArray).mutableCopy() as! NSMutableArray
        }
        // Do any additional setup after loading the view.
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.historyArray.count
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = UITableViewCell(style: .subtitle, reuseIdentifier: "cell")
        cell.selectionStyle = .none
        let dic = self.historyArray[indexPath.row] as! NSDictionary
        cell.textLabel?.text = (dic.object(forKey: "code") as! String)
        cell.detailTextLabel?.text = dic.object(forKey: "time") as? String
        cell.accessoryType = .disclosureIndicator
        let line = UIImageView(frame: CGRect(x: 0, y: 49.5, width: SCREEN_WIDTH, height: 0.5))
        line.backgroundColor = colorWithRGB(234, g: 234, b: 234, a: 1)
        cell.contentView.addSubview(line)
        return cell
        
        
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let dic = self.historyArray[indexPath.row] as! NSDictionary
        let result:XNErwDScanViewController = XNErwDScanViewController()
        result.urlString =  (dic.object(forKey: "code") as! String)
        self.pushViewController(viewController: result, animated: true)
        
    
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
